package com.sgb.kjwl.view.ui.adapter.transport;

import android.graphics.Paint;
import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sgb.kjwl.R;

import org.jetbrains.annotations.Nullable;

import java.util.List;

public class CargoManageHomeTabAdapter extends BaseQuickAdapter<String, BaseViewHolder> {
    private int selectIndex;

    public CargoManageHomeTabAdapter(@Nullable List<String> data) {
        super(R.layout.item_cargo_manage_home_tab, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, String item) {
        TextView tab = helper.getView(R.id.tv_tab_name);
        View line = helper.getView(R.id.v_tab_line);
        //
        tab.setText(item);
        //
        if (helper.getLayoutPosition() == selectIndex) {
            tab.setTextSize(16);
            tab.getPaint().setFlags(Paint.ANTI_ALIAS_FLAG | Paint.FAKE_BOLD_TEXT_FLAG);
            line.setVisibility(View.VISIBLE);
        } else {
            tab.setTextSize(15);
            tab.getPaint().setFlags(Paint.ANTI_ALIAS_FLAG);
            line.setVisibility(View.INVISIBLE);
        }
    }

    public void setSelectIndex(int selectIndex) {
        this.selectIndex = selectIndex;
        notifyDataSetChanged();
    }
}
